﻿using System;
using System.Collections.Generic;
using System.Windows.Input;

namespace Microsoft.Popfly.GameCreator.GameEngine.Events
{
    public class MouseLeftButtonDownEventChecker : IEventChecker
    {
        private BehaviorOwner m_listenOn;
        private Game m_game;

        public MouseLeftButtonDownEventChecker(Game game, BehaviorOwner listenOn)
        {
            m_listenOn = listenOn;
            listenOn.AddMouseLeftButtonListener();
            m_game = game;
        }

        public bool FireThisFrame(double elapsedTimeInSeconds, out BehaviorOwner sender, out PGCEventArgs args)
        {
            MouseButtonEventArgs mouseArgs = m_listenOn.IsMouseLeftButtonDownThisFrame();
            
            if (mouseArgs == null)
            {
                sender = null;
                args = null;
                return false;
            }
            else
            {   
                sender = m_listenOn;
                args = new PGCMouseButtonEventArgs(m_game, mouseArgs);
                return true;
            }
        }

        public bool IsOfEventType(string eventType)
        {
            return eventType == "mouse";
        }

    }
}
